Skip to content

fix(desktop): backfill SSH_AUTH_SOCK from login shell on macOS#972

Open
stickerdaniel wants to merge 2 commits intopingdotgg:mainfrom
stickerdaniel:fix/desktop-ssh-auth-sock
Open

fix(desktop): backfill SSH_AUTH_SOCK from login shell on macOS#972
stickerdaniel wants to merge 2 commits intopingdotgg:mainfrom
stickerdaniel:fix/desktop-ssh-auth-sock

Conversation

@stickerdaniel
Copy link

@stickerdaniel stickerdaniel commented Mar 12, 2026

Closes #971.

What Changed

  • replace the desktop-only fixPath() startup hook with syncShellEnvironment()
  • extend the shared login-shell probe so desktop startup can read multiple environment variables instead of only PATH
  • continue refreshing PATH on macOS startup, but only backfill SSH_AUTH_SOCK when it is missing
  • add desktop tests covering macOS hydration, non-macOS no-op behavior, and the regression case where an inherited SSH_AUTH_SOCK must be preserved

Why

The macOS desktop app currently repairs PATH from the login shell, but Finder and Dock launches can still miss SSH_AUTH_SOCK. That breaks Git-over-SSH flows in the desktop app even when the same repo works correctly from Terminal.

This keeps the fix small and reliability-focused:

  • Finder/Dock launches get the missing SSH agent socket they need
  • Terminal-launched sessions keep their inherited SSH_AUTH_SOCK instead of being overwritten by a different login-shell value
  • the server-side startup path is left unchanged so this PR stays desktop-scoped

UI Changes

None.

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • I included before/after screenshots for any UI changes
  • I included a video for animation/interaction changes

Note

Backfill SSH_AUTH_SOCK from login shell environment on macOS desktop app startup

  • Replaces fixPath() with a new syncShellEnvironment() utility in syncShellEnvironment.ts that reads both PATH and SSH_AUTH_SOCK from the user's login shell on macOS.
  • SSH_AUTH_SOCK is only set if not already present in the environment; PATH is always overwritten with the shell value if available.
  • Extracts a new readEnvironmentFromLoginShell helper in shell.ts that captures multiple env vars in a single shell invocation using per-variable start/end markers.
  • readPathFromLoginShell now delegates to readEnvironmentFromLoginShell and no longer fails when printenv PATH exits non-zero.
  • Behavioral Change: macOS desktop app now populates SSH_AUTH_SOCK at startup if the login shell has it set and the process does not.

Macroscope summarized a717465.

Copilot AI review requested due to automatic review settings March 12, 2026 10:42
@coderabbitai
Copy link

coderabbitai bot commented Mar 12, 2026

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 8cd1cd0a-1ec7-4ed7-84cf-c44fb700f960

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions bot added the vouch:unvouched PR author is not yet trusted in the VOUCHED list. label Mar 12, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR extends the shared “read env from login shell” utility so the macOS desktop app can hydrate more than just PATH at startup, specifically backfilling SSH_AUTH_SOCK when it’s missing (e.g., Finder/Dock launches) while preserving inherited values when present.

Changes:

  • Replaced the desktop-only fixPath() hook with syncShellEnvironment() and wired it into desktop startup.
  • Generalized the shared login-shell probe to support reading multiple environment variables (used for PATH + SSH_AUTH_SOCK).
  • Added unit tests for the shared shell helper and for desktop macOS/no-op/regression behavior.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
packages/shared/src/shell.ts Adds multi-variable login-shell environment capture/extraction and reimplements readPathFromLoginShell on top of it.
packages/shared/src/shell.test.ts Updates PATH probe test markers and adds tests for multi-variable extraction behavior.
apps/desktop/src/syncShellEnvironment.ts New macOS-only startup hook to sync PATH and backfill missing SSH_AUTH_SOCK.
apps/desktop/src/syncShellEnvironment.test.ts Adds tests for macOS hydration, preservation of inherited SSH_AUTH_SOCK, omission behavior, and non-macOS no-op.
apps/desktop/src/main.ts Switches startup hook from fixPath() to syncShellEnvironment().
apps/desktop/src/fixPath.ts Removes the previous desktop-only PATH fix implementation.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] macOS desktop app does not inherit SSH_AUTH_SOCK from login shell when launched outside Terminal

2 participants